home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / esc.jar / com / extensibility / xml / XSDLFlavor.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-30  |  5.7 KB  |  122 lines

  1. package com.extensibility.xml;
  2.  
  3. import com.extensibility.xml.dt.DataType;
  4. import com.extensibility.xml.dt.DataTypeEnumeration;
  5. import com.extensibility.xml.dt.DataTypeFactory;
  6. import com.extensibility.xml.dt.DataTypeIntf;
  7. import java.io.IOException;
  8. import java.io.Writer;
  9. import java.util.Enumeration;
  10. import java.util.Hashtable;
  11.  
  12. public class XSDLFlavor extends BaseFlavor {
  13.    public static final String NAME = "xsd";
  14.    public static final String[] XSD_ALL_TYPES;
  15.    public static final String[] XSD_OTHER_TYPES;
  16.    public static final String[] XSD_SIMPLE_TYPES;
  17.    public static final String[] XSD_ATTR_TYPES;
  18.    static Hashtable xsdSourceNames;
  19.  
  20.    XSDLFlavor(SchemaIntf var1) {
  21.       super(var1);
  22.    }
  23.  
  24.    public String getFlavorName() {
  25.       return "xsd";
  26.    }
  27.  
  28.    public boolean isSupported(Class var1) {
  29.       return !var1.equals(Class.forName("com.extensibility.xml.GeneralEntityDeclaration")) && !var1.equals(Class.forName("com.extensibility.xml.InternalGEDeclaration")) && !var1.equals(Class.forName("com.extensibility.xml.ExternalGEDeclaration")) && !var1.equals(Class.forName("com.extensibility.xml.ParameterEntityDeclaration")) && !var1.equals(Class.forName("com.extensibility.xml.InternalPEDeclaration")) && !var1.equals(Class.forName("com.extensibility.xml.ExternalPEDeclaration"));
  30.    }
  31.  
  32.    public void parse(URI var1, URI var2, int var3, Object var4) throws IOException {
  33.       (new XSDLReader(super.schema)).parse(var1, var2);
  34.    }
  35.  
  36.    public void write(Writer var1) throws IOException {
  37.       this.write(var1, super.schema.getURI());
  38.    }
  39.  
  40.    public void write(Writer var1, URI var2) throws IOException {
  41.       (new XSDLWriter(super.schema, var2)).writeDocument(var1);
  42.    }
  43.  
  44.    public String getSourcePreview(BaseDeclaration var1) {
  45.       return (new XSDLWriter(super.schema)).getSourcePreview(var1);
  46.    }
  47.  
  48.    public void checkForErrors(BaseDeclaration var1) {
  49.       super.checkForErrors(var1);
  50.    }
  51.  
  52.    public boolean isSupported(String var1) {
  53.       return !var1.equals("GESTALT_OPEN_CONTENT") && !var1.equals("GESTALT_LOCAL_TAG") && !var1.equals("GESTALT_MIN_MAX_OCCURS") && !var1.equals("GESTALT_MULTI_INSTANCE_MODULES") && !var1.equals("GESTALT_NMTOKEN_ENUM_REQUIRED") && !var1.equals("GESTALT_REUSABLE_CONTENTMODEL") && !var1.equals("GESTALT_REUSABLE_ATTRIBUTEGROUP") && !var1.equals("GESTALT_FACET_MINLENGTH") && !var1.equals("GESTALT_FACET_LENGTH") && !var1.equals("GESTALT_FACET_ENCODING") && !var1.equals("GESTALT_FACET_PERIOD") && !var1.equals("GESTALT_FACET_PATTERN") && !var1.equals("GESTALT_FACET_DECIMALS") && !var1.equals("GESTALT_FACET_DIGITS") && !var1.equals("GESTALT_FACET_MIN") && !var1.equals("GESTALT_FACET_MAX") && !var1.equals("GESTALT_FACET_MINEX") && !var1.equals("GESTALT_FACET_MAXEX") && !var1.equals("GESTALT_FACET_MAXLENGTH") ? super.isSupported(var1) : true;
  54.    }
  55.  
  56.    public DataTypeEnumeration getAllTypes() {
  57.       return DataTypeFactory.getTheseTypes(XSD_ALL_TYPES);
  58.    }
  59.  
  60.    public DataTypeEnumeration getSimpleTypes() {
  61.       return DataTypeFactory.getTheseTypes(XSD_SIMPLE_TYPES);
  62.    }
  63.  
  64.    public DataTypeEnumeration getPrimitiveTypes() {
  65.       return DataTypeFactory.getTheseTypes(XSD_ATTR_TYPES);
  66.    }
  67.  
  68.    public DataTypeEnumeration getOtherTypes() {
  69.       Enumeration var1 = super.schema.getDeclarations(Class.forName("com.extensibility.xml.DataTypeDeclaration"));
  70.       return new 1.XSDDataTypeEnum((XSDLFlavor)null, var1);
  71.    }
  72.  
  73.    private static void loadXsdSourceNames() {
  74.       xsdSourceNames = new Hashtable();
  75.  
  76.       for(int var0 = 0; var0 < XSD_ALL_TYPES.length; ++var0) {
  77.          xsdSourceNames.put(BaseFlavor.getDisplay("xsd", XSD_ALL_TYPES[var0]), XSD_ALL_TYPES[var0]);
  78.       }
  79.  
  80.    }
  81.  
  82.    public boolean isKnownDisplay(String var1) {
  83.       if (xsdSourceNames == null) {
  84.          loadXsdSourceNames();
  85.       }
  86.  
  87.       String var2 = (String)xsdSourceNames.get(var1);
  88.       return var2 == null ? false : DataTypeFactory.isKnown(var2);
  89.    }
  90.  
  91.    public DataType createDataTypeFromDisplay(String var1) {
  92.       if (xsdSourceNames == null) {
  93.          loadXsdSourceNames();
  94.       }
  95.  
  96.       String var2 = (String)xsdSourceNames.get(var1);
  97.       if (var2 == null) {
  98.          var2 = var1;
  99.       }
  100.  
  101.       return DataTypeFactory.createDataType(var2);
  102.    }
  103.  
  104.    public URI getSchemaLoc(NamespaceDeclaration var1) {
  105.       URI var2 = var1.getSchemaLoc();
  106.       if (var2 != null) {
  107.          return var2;
  108.       } else {
  109.          String var3 = var1.getNamespace();
  110.          return var3 == null ? null : new URI(var3);
  111.       }
  112.    }
  113.  
  114.    static {
  115.       XSD_ALL_TYPES = new String[]{DataTypeIntf.STRING, DataTypeIntf.INT, DataTypeIntf.DECIMAL, DataTypeIntf.BOOLEAN, DataTypeIntf.DATETIME, DataTypeIntf.DATE, DataTypeIntf.TIME, DataTypeIntf.URI, DataTypeIntf.ID, DataTypeIntf.IDREF, DataTypeIntf.IDREFS, DataTypeIntf.ENTITY, DataTypeIntf.ENTITIES, DataTypeIntf.NMTOKEN, DataTypeIntf.NMTOKENS, DataTypeIntf.NOTATION, DataTypeIntf.R4, DataTypeIntf.R8, DataTypeIntf.BINBASE64};
  116.       XSD_OTHER_TYPES = new String[]{""};
  117.       XSD_SIMPLE_TYPES = new String[]{DataTypeIntf.STRING, DataTypeIntf.INT, DataTypeIntf.DECIMAL, DataTypeIntf.BOOLEAN, DataTypeIntf.DATETIME, DataTypeIntf.DATE, DataTypeIntf.TIME, DataTypeIntf.URI, DataTypeIntf.R4, DataTypeIntf.R8, DataTypeIntf.BINBASE64};
  118.       XSD_ATTR_TYPES = new String[]{DataTypeIntf.STRING, DataTypeIntf.ID, DataTypeIntf.IDREF, DataTypeIntf.IDREFS, DataTypeIntf.ENTITY, DataTypeIntf.ENTITIES, DataTypeIntf.NOTATION, DataTypeIntf.NMTOKEN, DataTypeIntf.NMTOKENS};
  119.       xsdSourceNames = null;
  120.    }
  121. }
  122.